<h2>
  <?php echo $this->translate("Advanced Footer Menu") ?>
</h2>
<p>
  <?php echo $this->translate("Add a professional footer menu to your socialengine website. Based on popular commercial footers.") ?>
</p>
<br/>
<?php if( count($this->navigation) ): ?>
  <div class='tabs'>
    <?php
      // Render the menu
      //->setUlClass()
      echo $this->navigation()->menu()->setContainer($this->navigation)->render()
    ?>
  </div>
<?php endif; ?>
<br/>
<script type="text/javascript">
  en4.core.runonce.add(function(){$$('th.admin_table_short input[type=checkbox]').addEvent('click', function(){ $$('input[type=checkbox]:not(:disabled)').set('checked', $(this).get('checked', false)); })});

  var changeOrder =function(orderby, direction){
    $('orderby').value = orderby;
    $('orderby_direction').value = direction;
    $('filter_form').submit();
  }

  var delectSelected =function(){
    var checkboxes = $$('input[type=checkbox]');
    var selecteditems = [];

    checkboxes.each(function(item, index){
      var checked = item.get('checked', false);
      var value = item.get('value', false);
      if (checked == true && value != 'on'){
        selecteditems.push(value);
      }
    });

    $('ids').value = selecteditems;
	if (selecteditems.length > 0)
      $('delete_selected').submit();
  }

</script>

<?php echo $this->form->render($this) ?>

<br />

<div class="admin_results">
  <div>
    <?php echo $this->htmlLink(array('action' => 'create', 'reset' => false), $this->translate('Add Collection'), array(
      'class' => 'buttonlink',
      'style' => 'background-image: url(' . rtrim($this->baseUrl(), '/') . '/application/modules/Footermenu/externals/images/admin/add.png);'
    )) ?>
  </div>
  <div>
    <?php $collectionCount = $this->paginator->getTotalItemCount(); ?>
    <?php echo $this->translate(array("%d collection found","%d collections found", $collectionCount), $collectionCount); ?>
  </div>
  <div>
    <?php echo $this->paginationControl($this->paginator); ?>
  </div>
</div>

<br />

<table class='admin_table'>
  <thead>
    <tr>
      <th style="width: 1%;" class="admin_table_short"><input type='checkbox' class='checkbox' /></th>
      <th style="width: 1%;">ID</th>
      <th style="width: 30%;">
        <?php echo $this->translate("Collection Name") ?>
      </th>
      <th><?php echo $this->translate("Description") ?></th>      
      <th style="width: 1%;"><?php echo $this->translate("Categories") ?></th>
      <th style="width: 10%;"><?php echo $this->translate("Options") ?></th>
    </tr>

  </thead>
  <tbody>
    <?php if( count($this->paginator) ): ?>
      <?php foreach( $this->paginator as $item ): ?>
        <tr>
        <td><input type='checkbox' class='checkbox' value="<?php echo $item->collection_id?>"></td>
          <td>
            <?php echo $item->collection_id ?>
          </td>
          <td class="admin_table_bold">
            <a href='<?php echo $this->url(array('action' => 'category', 'collection_id' => $item->collection_id)) ?>'>
              <?php echo $this->translate($item->collection) ?>
            </a>  
          </td>
          <td>
            <?php echo $this->translate($item->description) ?>
          </td>          
          <td style="text-align: center;">
            <?php $categoriesCount = $this->footermenuCategories($item->collection_id); ?>
            <?php echo $categoriesCount ?>
          </td>
          <td class="admin_table_options">
            <a href='<?php echo $this->url(array('action' => 'edit', 'id' => $item->collection_id)) ?>'>
              <?php echo $this->translate("edit") ?>
            </a>
            |
            <a href='<?php echo $this->url(array('action' => 'delete', 'id' => $item->collection_id)) ?>'>
              <?php echo $this->translate("delete") ?>
            </a>
          </td>
        </tr>
      <?php endforeach; ?>
    <?php endif; ?>
  </tbody>

</table>

<br/>
<div class='buttons'>
  <button onclick="javascript:delectSelected();" type='submit'>
    <?php echo $this->translate("Delete Selected") ?>
  </button>
</div>

<form id='delete_selected' method='post' action='<?php echo $this->url(array('action' =>'deleteselected')) ?>'>
  <input type="hidden" id="ids" name="ids" value=""/>
</form>